<template>
<div>
  <Row style="text-align: left" >
    <i-col span="24">
      <div style="text-align: right;" class="order_btns">
        <Button type="info" icon="ios-download-outline" @click="exportOrderTurnover" v-has=tRole.ORDER_1_109>导出订单流水</Button>
        <Button type="info" icon="ios-download-outline" @click="exportReport" v-has=tRole.ORDER_1_102>导出报表</Button>
        <Button type="info" @click="showExportTransferExcel" icon="ios-download-outline" v-has=tRole.ORDER_1_103>物流对接单</Button>
        <Button type="info" @click="exportPurchaseOrders" icon="ios-download-outline" v-has=tRole.ORDER_1_107>导出采购单</Button>
        <Button type="info" @click="batchExportOrdersBlank" icon="ios-download-outline" v-has=tRole.ORDER_1_104>导出配货单</Button>
        <Button type="info" @click="batchExportOrdersInvoice" icon="ios-download-outline" v-has=tRole.ORDER_1_105>导出发货单</Button>
        <Button type="info" @click="batchExportProductCodes" icon="ios-download-outline" v-has=tRole.ORDER_1_108>导出产品编码</Button>
        <Button type="info" @click="batchExportTradeData" icon="ios-download-outline" v-has=tRole.ORDER_1_115>导出跨境认证数据</Button>
        <Button type="primary" @click="showPrepareModal" icon="ios-cart" v-has=tRole.ORDER_1_112>订单备货</Button>
        <Button type="primary" @click="showStockOutModal" icon="md-send" v-has=tRole.ORDER_1_113>订单出库</Button>
        <Button type="primary" @click="showImportantNoteModal" icon="md-create" v-has=tRole.ORDER_1_110>修改重要说明</Button>
        <Button type="primary" @click="removeImportantNote" icon="md-close" v-has=tRole.ORDER_1_110>清除重要说明</Button>
      </div>
      <divider></divider>

        <div class="y_query_right">
          <Select placeholder="请选择订单状态" v-model="tParams.orderState" class="y_condition" clearable style="text-align: left;">
            <Option value="1">全部状态</Option>
            <Option v-for="item in orderStateEnum" :value="item.code" :key="item.code">{{ item.cnName }}</Option>
          </Select>
          <Input v-model.trim="tParams.orderSerialNumber" placeholder="订单流水号" clearable class="y_condition"></Input>
          <Input v-model.trim="tParams.userName" placeholder="请输入用户名" clearable class="y_condition"></Input>
          <Input v-model.trim="tParams.waybill" placeholder="请输入物流单号" clearable class="y_condition"></Input>
          <DatePicker type="datetime" v-model="tParams.startTime" format="yyyy-MM-dd HH:mm" class="y_condition" placeholder="选择起始时间"></DatePicker>-&nbsp;&nbsp;&nbsp;
          <DatePicker type="datetime" v-model="tParams.endTime" format="yyyy-MM-dd HH:mm" class="y_condition" placeholder="选择结束时间"></DatePicker>
          <Button type="primary"  class="y_condition" icon="ios-search" @click="search">查询</Button>
        </div>
    </i-col>
  </Row>
  <List  style="margin-top: 1rem" border>
    <ListItem style="display: flex;flex-direction: column;align-items: flex-start;">
      <Checkbox v-model="isCheckedAllMessage" @on-change="handleCheckAll" >全选</Checkbox>
    </ListItem>

    <CheckboxGroup v-model="tParams.selectedOrders" @on-change="checkChange">
    <ListItem v-for="(item,index) in tData.orderList" :key="item.id">
      <div style="width: 100%;text-align: left">
        <Row type="flex"  justify="start"  >
          <i-col style="margin-right: 1rem;">
            <Checkbox :label="item" :value="index">{{ check }}</Checkbox>
          </i-col>

          <i-col>
            <Tag color="magenta" v-if="item.firstOrder ===1">首单</Tag>
            <Tag color="blue" v-if="item.firstOrder===2">复购</Tag>
            <Tag color="default" v-if="item.firstOrder===3">普通</Tag>
            <Tooltip :content="item.serialNumber">
              <span class="base_key">订单短号: <span class="base_value">{{ showShortNo(item.serialNumber) }}</span></span>
            </Tooltip>
            <KeyValueView title="金额" :value="'US$ '+item.actualPayment"></KeyValueView>
            <span class="base_key">订单状态: <span v-if="orderStateEnum.filter(i => i.code == item.orderState.state).length>0" class="base_value">{{orderStateEnum.filter(i => i.code == item.orderState.state)[0].cnName}}</span></span>
            <span class="base_key">发货状态: <span v-if="shipStateEnum.filter(i => i.code == item.orderState.shipState).length>0" class="base_value">{{shipStateEnum.filter(i => i.code == item.orderState.shipState)[0].cnName}}</span></span>
            <KeyValueView v-if="hasAuth('ORDER-1-218')" title="用户" ><a @click="showUserContactInfo(item)">{{item.encodeName}}</a></KeyValueView>
            <KeyValueView v-else title="用户" >{{item.encodeName}}</KeyValueView>
            <KeyValueView title="国家" :value="item.countryName"></KeyValueView>
            <KeyValueView v-if="isNotEmpty(item.checkoutTime)" title="付款时间" >{{$tiyBJTime(item.checkoutTime)}}</KeyValueView>
            <KeyValueView v-if="isEmpty(item.checkoutTime)" title="下单时间" >{{$tiyBJTime(item.createtime)}}</KeyValueView>

            <KeyValueView v-if="isNotEmpty(item.note)" oneline title="用户备注" >{{item.note}}.</KeyValueView>
            <KeyValueView v-if="isNotEmpty(item.importantNote)" oneline title="重要说明" >{{item.importantNote}}.</KeyValueView>
            <KeyValueView v-if="item.innerNoteText" oneline title="运营备注" ><Button size="small" @click="showInnerNote(item.id)" type="text" ghost style="color:dodgerblue;">点击查看</Button></KeyValueView>

          </i-col>
        </Row>

        <Row justify="space-between" style="padding-top: 0.25rem">
          <i-col span="24" align="right">

            <router-link v-if="item.orderState.state==112 || item.orderState.state==113 || item.orderState.state==114|| item.orderState.state==115" :to="{name:'purchase',params:{id:item.id,serialNumber:item.serialNumber,checkoutTime:item.checkoutTime,countryName:item.countryName,actualPayment:item.actualPayment,orderState:item.orderState}}">
              <Button size="small" type="success" ghost style="margin-left: 0.5rem">采/退/补货</Button>
            </router-link>
            <router-link  v-if="!item.isHistoryOrder&&(item.orderState.shipState==111 || item.orderState.shipState==112|| item.orderState.shipState==114)" :to="{name:'newOrderShip',params:{shortOrderInfo:{'id':item.id,'serialNumber':item.serialNumber,'checkoutTime':item.checkoutTime,'country':item.country,'actualPayment':item.actualPayment,'deliveryMethod':item.deliveryMethod,'orderState':item.orderState}}}">
              <Button size="small" type="info" ghost style="margin-left: 0.5rem">拆单发货</Button>
            </router-link>

            <router-link :to="{name:'newOrderDetails',params:{id:item.id}}">
              <Button size="small" type="primary" ghost style="margin-left: 0.5rem">订单详情</Button>
            </router-link>

          </i-col>

        </Row>
      </div>

    </ListItem>
    </CheckboxGroup>

    <div style="text-align: right;padding: 1rem 0">
      <Page :total="tPage.total" :page-size="tPage.stepNumber" :current="tPage.currentPage" @on-change="changePage"
            @on-page-size-change="sizeChange" :page-size-opts="[20,40,60,100]"
            show-sizer show-elevator/>
    </div>

  </List>

  <!--查看用户详细联系信息弹出框-->
  <Modal v-model="status.modalUserContactInfo.isShow" title="用户联系方式"
         :styles="{align:'center',width:'60%',padding:'2rem'}" :scrollable=true >
    <!--      <Row>-->
    <!--        <i-col span="10">-->
    <!--          <div> <span class="key">国家电话代码 :</span> {{status.modalUserContactInfo.info.phoneCode}}</div>-->
    <!--        </i-col>-->
    <!--        <i-col span="10">-->
    <!--          <div><span class="key">联系电话 :</span> {{status.modalUserContactInfo.info.mobile}}</div>-->
    <!--        </i-col>-->
    <!--      </Row>-->
    <!--      <Row>-->
    <!--        <i-col span="10">-->
    <!--          <div> <span class="key">Facebook :</span> {{status.modalUserContactInfo.info.facebook}}</div>-->
    <!--        </i-col>-->
    <!--        <i-col span="10">-->
    <!--          <div><span class="key">Instagram :</span> {{status.modalUserContactInfo.info.instagram}}</div>-->
    <!--        </i-col>-->
    <!--      </Row>-->
    <Row>
      <i-col span="10">
        <div> <span class="key">联系邮箱 :</span> {{$tiyHideEmail(status.modalUserContactInfo.info.email)}}
          <Button size="small" type="info" ghost style="" @click="copyEmail(status.modalUserContactInfo.info.email)" icon="md-copy" v-has=tRole.ORDER_1_221 >
            copy
          </Button>

        </div>

      </i-col>
      <!--        <i-col span="14">-->
      <!--          <div><span class="key">独立站 :</span><a v-if="status.modalUserContactInfo.info.web != null" target='_blank' :href="tStatus.modalUserContactInfo.info.web">{{status.modalUserContactInfo.info.web}}</a> </div>-->
      <!--        </i-col>-->
    </Row>
    <Row style="margin-top: 5px">
      <i-col span="8">
        <Button type="info" style="" @click="showEmail" icon="md-mail"
                v-has=tRole.ORDER_1_221 >发送邮件
        </Button>
      </i-col>
    </Row>
    <div slot="footer">
      <Button type="primary" @click="status.modalUserContactInfo.isShow = false;">确定</Button>
    </div>
  </Modal>

  <!-- 发送邮件 -->
  <Modal
    v-model="showEmailState.isShowing"
    title=""
    :mask-closable="false"
    :styles="{top: '20px',bottom:'20px',width:'80%'}">
    <send-email v-bind:receiveUser="showEmailState.selectedUsers" v-bind:isRefresh="showEmailState.isShowing"
                     v-on:listenSendEmailEvent="sendSuccess" :is-send="false"  ref="SendEmail"></send-email>
    <div slot="footer"></div>
  </Modal>

  <!-- 运营备注 -->
  <Modal
    v-model="status.modalInnerNote.isShow"
    title="运营备注"
    width="65"
    :styles="{align:'center'}"
    :scrollable=true>
    <List v-if="tData.innerNoteList.length>0" border size="small">
      <ListItem v-for="(item,index) in tData.innerNoteList" >
        <row style="width:100%;">
          <i-col  span="24">
            <span style="font-weight: bold;">{{index+1}}.</span><span > {{item.content}}</span>
            <span style="float:right"><tag color="red">{{item.employeeName}}</tag> {{$tiyBJTime(item.createtime)}}</span>
          </i-col>
        </row>

      </ListItem>
    </List>
  </Modal>

  <Modal v-model="status.modalExportTransferExcel.isShow" title="物流对接单" @on-ok="exportTransferExcel()" :closable="false" :mask-closable="false">
    <Row>
      <span class="key">选择需要导出的物流对接单</span>
    </Row>
    <Row>
      <RadioGroup v-model="tParams.transferExcelType" vertical>
        <Radio label="1">
          <span>W物流对接单</span>
        </Radio>
        <!--          <Radio label="2">-->
        <!--            <span>EMS物流对接单</span>-->
        <!--          </Radio>-->
        <Radio label="3">
          <span>DHL物流对接单</span>
        </Radio>
      </RadioGroup>
    </Row>
  </Modal>

  <!--确认弹出框-->
  <Modal
    v-model="status.modalAction.isShow"
    :title="status.modalAction.title"
    :loading="status.modalAction.isLoading"
    @on-ok="actionOk">
    <br>
    <p>{{status.modalAction.content}}?</p>
    <br>
  </Modal>

  <!-- 修改重要说明对话框 -->
  <Modal v-model="status.modalImportantNote.isShow" title="修改重要说明" :closable="false" :mask-closable="false" label-c>
    <Form  label-colon :label-width="80">
      <div style="color: #ff9900; margin-bottom: 10px; margin-left: 10px;">
        <Icon type="md-warning" size="20"></Icon>订单原来的重要说明会被覆盖
      </div>
      <FormItem label="重要说明" prop="importantNote">
        <Input type="textarea" v-model.trim="tParams.modifyImportantNote.importantNote" :rows="5" style="width: 90%;"/>
        <Icon type="ios-close-circle" @click="clearImportantNote()" style="position: absolute; margin-left: -18px; margin-top: 5px;"/>
      </FormItem>
    </Form>
    <div slot="footer">
      <Button @click="status.modalImportantNote.isShow=false">取消</Button>
      <Button type="primary" @click="modifyImportantNote()">保存</Button>
    </div>
  </Modal>

  <!--确认弹出框-->
  <Modal
    v-model="status.modalConfirm.isShow"
    :title="status.modalConfirm.title"
    :isLoading="status.modalConfirm.isLoading"
    @on-ok="status.modalConfirm.onOk()"
  >
    <br>
    <p>{{status.modalConfirm.content}}</p>
    <br>
  </Modal>

</div>
</template>

<script>
import KeyValueView from "../widgets/KeyValueView";
import tiyData from "./js/orderList/newOrder_data";
import {isNotEmpty,isEmpty} from "../js/commonUtils";
import SendEmail from "../email/SendEmailTemplate.vue"
import {init,isFirstOrder,getShortNo,webList,
  exportTransferExcel,
  prepareOrders,
  exportReport,
  clearSelectedOrders,
  stockOutOrders,
  getUserContactInfo,
  batchExportOrdersBlank,
  batchExportOrdersInvoice,
  exportMiaozhangSale,
  exportPurchaseOrders,
  exportProductCodeForPrint,
  exportOrderTurnover,
  modifyImportantNote,
  exportTradeData} from "./js/orderList/newOrder_fun";

export default {
  data(){
    return{
      tRole:{//权限
        ORDER_1_101:"ORDER-1-101",
        ORDER_1_102:"ORDER-1-102",
        ORDER_1_103:"ORDER-1-103",
        ORDER_1_111:"ORDER-1-111",
        ORDER_1_112:"ORDER-1-112",
        ORDER_1_113:"ORDER-1-113",
        ORDER_1_221:"ORDER-1-221",
        ORDER_1_104:"ORDER-1-104",
        ORDER_1_105:"ORDER-1-105",
        ORDER_1_106:"ORDER-1-106",
        ORDER_1_107:"ORDER-1-107",
        ORDER_1_108:"ORDER-1-108",
        ORDER_1_109:"ORDER-1-109",
        ORDER_1_219: "ORDER-1-219",
        ORDER_1_110: "ORDER-1-110",
        ORDER_1_114: "ORDER-1-114",
        ORDER_1_115: "ORDER-1-115",
        COMMON_1_100:"COMMON-1-100",
      },
      tPage: tiyData.tPage,
      tData: tiyData.tData,
      status: tiyData.tStatus,
      tParams: tiyData.tParams,
      check: '',
      isCheckedAllMessage: false,
      orderStateEnum: this.$store.getters.order.orderStateEnum,
      shipStateEnum:this.$store.getters.order.shipStateEnum,
      showEmailState:{// 发送邮件相关的状态
        isShowing:false,
        selectedUsers:[// 测试数据
          {
            contactEmail:"545794510@qq.com.com",
            encodeName:"Jacqueline",
            fullEmail:" Vary",
          },
        ],
      },
    }
  },
  methods:{
    checkChange(val) {
      if (tiyData.tParams.selectedOrders.length == this.tData.orderList.length) {
        this.isCheckedAllMessage = true;
      } else {
        this.isCheckedAllMessage = false;
      }
    },
    handleCheckAll() {
      let self = this;
      if (this.isCheckedAllMessage) {
        tiyData.tParams.selectedOrders.splice(0, tiyData.tParams.selectedOrders.length);
        tiyData.tParams.selectedOrders=[...this.tData.orderList];
      } else {
        tiyData.tParams.selectedOrders.splice(0, tiyData.tParams.selectedOrders.length);
      }
    },
    isNotEmpty(val) {
      return isNotEmpty(val);
    },
    isEmpty(val) {
      return isEmpty(val);
    },
    search(){
      tiyData.tPage.currentPage = 1;
      webList(this, tiyData,1);
    },
    showShortNo(serialNumber){
      return getShortNo(serialNumber);
    },
    changePage(page) {
      tiyData.tPage.currentPage = page;
      webList(this, tiyData,1);
    },
    copyEmail(email){
      var oInput = document.createElement('input');
      oInput.value = email;
      document.body.appendChild(oInput);
      oInput.select(); // 选择对象
      document.execCommand("Copy"); // 执行浏览器复制命令
      oInput.className = 'oInput';
      oInput.style.display = 'none';
      this.$Message.success('邮箱地址已复制');
    },
    sizeChange(page) {
      tiyData.tPage.stepNumber = page;
      webList(this, tiyData,1);
    },
    showUserContactInfo(user){
      tiyData.tStatus.modalUserContactInfo.info.userName = user.userName;
      tiyData.tStatus.modalUserContactInfo.info.encodeName = user.encodeName;
      getUserContactInfo(this, tiyData, user.userId);
    },
    showEmail(){
      this.showEmailState.selectedUsers.length = 0;
      this.showEmailState.selectedUsers.push({
        contactEmail:tiyData.tStatus.modalUserContactInfo.info.email,
        encodeName:tiyData.tStatus.modalUserContactInfo.info.encodeName,
      });
      this.showEmailState.isShowing = true;
    },
    sendSuccess(isSuccess){
      if(isSuccess){
        this.showEmailState.isShowing = false;
      }
    },
    hasAuth(path){
      return this.$authority(path);
    },
    isFirstOrder(firstOrder){
      return isFirstOrder(firstOrder);
    },
    showInnerNote(orderId){
      let self=this;
      self.$ySpliceAll(self.tData.innerNoteList);
      let params={orderId:orderId};
      let hasNote = false;
      self.$apiOrder.getInnerNoteList(params).then(function (response) {
        if (response.success) {
          let list=response.result;
          if(list && list.length > 0){
            hasNote = true;
            list.forEach(function(item){
              self.tData.innerNoteList.push(item);
            });
          }
        }
        if(hasNote){
          self.status.modalInnerNote.isShow=true;
        } else {
          self.$Message.error("此订单没有运营备注。");
        }
      });
    },
    showImportantNoteModal() {
      let checked = this.checkSelectedOrderState();
      if(checked.success) {
        this.tParams.modifyImportantNote.orderIds = tiyData.tParams.selectedOrders.map(obj => {return obj.id});
        this.tParams.modifyImportantNote.importantNote = "";
        // console.log(this.params.modifyImportantNote.orderIds);
        this.status.modalImportantNote.isShow = true;
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    clearImportantNote() {
      this.tParams.modifyImportantNote.importantNote = "";
    },
    modifyImportantNote() {
      // this.status.modalConfirm.title = "确认提示";
      // this.status.modalConfirm.content = "订单原来的重要说明会被覆盖，确认继续保存吗？";
      // let self = this;
      // this.status.modalConfirm.onOk = () => {
      //   modifyImportantNote(self, tiyData);
      // };
      // this.status.modalConfirm.isShow = true;
      modifyImportantNote(this, tiyData);
    },
    removeImportantNote() {
      let checked = this.checkSelectedOrderState();
      if(checked.success) {
        this.tParams.modifyImportantNote.orderIds = tiyData.tParams.selectedOrders.map(obj => {return obj.id});
        this.tParams.modifyImportantNote.importantNote = "";
        // console.log(this.params.modifyImportantNote.orderIds);
        this.status.modalConfirm.title = "确认提示";
        this.status.modalConfirm.content = "确定要清除所选订单的重要说明吗？";
        let self = this;
        this.status.modalConfirm.onOk = () => {
          modifyImportantNote(self, tiyData);
        };
        this.status.modalConfirm.isShow = true;
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    actionOk(){
      if(tiyData.tStatus.modalAction.type==0){//备货
        this.prepareOrders();
      }else if(tiyData.tStatus.modalAction.type==1){//出库
        this.stockOutOrders();
      }
    },
    prepareOrders(){
      let checked = this.checkSelectedOrderState(3);
      if(checked.success){
        prepareOrders(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    stockOutOrders(){//订单出库
      let checked = this.checkSelectedOrderState(4);
      if(checked.success){
        stockOutOrders(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    checkSelectedOrderState(type){ //列表点击按钮前判断选中订单状态
      let ret = {"success" : true};
      if(tiyData.tParams.selectedOrders.length <= 0){
        ret.success = false;
        ret.error = "先选择订单！";
        return ret;
      }
      for(let i = 0; i < tiyData.tParams.selectedOrders.length; i++){
        let order = tiyData.tParams.selectedOrders[i];
        switch(type){
          case 1: //ems物流对接单、配货单
            if(order.state != 115  && order.state != 113 && order.state != 114){
              ret.success = false;
              ret.error = "只能导出“确认收款”、“备货”和“出库”状态的订单！";
              return ret;
            }
            break;
          case 2: //订单确认
            if(order.state != 110 && order.state != 116) {
              ret.success = false;
              ret.error = "只能对“已支付”和“待确认”状态的订单执行确认操作！";
            }
            break;
          case 3: //订单备货
            if(order.state != 115) {
              ret.success = false;
              ret.error = "只能对“已确认”状态的订单执行备货操作！";
            }
            break;
          case 4: //订单出库
            if(order.state != 113) {
              ret.success = false;
              ret.error = "只能对“备货”状态的订单执行出库操作！";
            }
            break;
          case 5: //发货单
            if(order.state < 111 || order.state > 115){
              ret.success = false;
              ret.error = "只能导出“确认收款”、“备货”、“出库”和“发货”状态的订单！";
              return ret;
            }
            break;
          case 6: //秒帐销售单
            if(order.state <=110 || order.state == 116 || order.state == 120 || order.state == 121){
              ret.success = false;
              ret.error = "不能导出款项未到账和已退款的订单！";
              return ret;
            }
            break;
          case 7: //跨境电商认证数据
            if(order.state != 100) {
              ret.success = false;
              ret.error = "不能导出款项未到账和已退款的订单！"
            }
            break;
          default :
            break;
        }
      }
      return ret;
    },
    exportTransferExcel(){
      let checked = this.checkSelectedOrderState(1);
      if(checked.success){
        exportTransferExcel(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    showPrepareModal(){
      let checked = this.checkSelectedOrderState(3);
      if(checked.success) {
        tiyData.tStatus.modalAction.title = "订单备货确认";
        tiyData.tStatus.modalAction.content = "确认备货已选中的订单";
        tiyData.tStatus.modalAction.type = 0;
        tiyData.tStatus.modalAction.isShow = true;
      }else{
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });

      }
    },
    showStockOutModal(){
      let checked = this.checkSelectedOrderState(4);
      if(checked.success){
        tiyData.tStatus.modalAction.title="订单出库确认";
        tiyData.tStatus.modalAction.content="确认出库已选中的订单吗";
        tiyData.tStatus.modalAction.type=1;
        tiyData.tStatus.modalAction.isShow=true;
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }

    },
    exportPurchaseOrders() { //导出订单采购单
      let checked = this.checkSelectedOrderState(6);
      if (checked.success) {
        exportPurchaseOrders(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width: 500,
          onOk: function () {
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    batchExportOrdersBlank(){ //批量导出配货单
      let checked = this.checkSelectedOrderState(1);
      if(checked.success){
        batchExportOrdersBlank(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    batchExportOrdersInvoice(){ //批量导出发货单
      let checked = this.checkSelectedOrderState(5);
      if(checked.success){
        batchExportOrdersInvoice(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width:500,
          onOk : function(){
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    batchExportProductCodes() { //导出订单产品编码，用于打印
      let checked = this.checkSelectedOrderState(5);
      if (checked.success) {
        exportProductCodeForPrint(this, tiyData);
      } else {
        let self = this;
        this.$Modal.error({
          title: "error",
          content: checked.error,
          width: 500,
          onOk: function () {
            clearSelectedOrders(self, tiyData);
          }
        });
      }
    },
    exportReport(){
      exportReport(this, tiyData);
    },
    exportOrderTurnover() {
      exportOrderTurnover(this, tiyData);
    },
    showExportTransferExcel() {
      tiyData.tStatus.modalExportTransferExcel.isShow = true;
      tiyData.tParams.transferExcelType = 3;
    },
    batchExportTradeData() {
      let checked = this.checkSelectedOrderState(7);
      exportTradeData(tiyData, this);
    }
  },
  components: {
    KeyValueView,SendEmail,
  },
  mounted() {
    init(this,tiyData,1);
  }
}
</script>

<style scoped lang="less">
@import  (once,optional) "../css/base.less";

.order_btns{
  button{
    margin-bottom: 0.5rem;
  }
}
</style>
